package cn.itcast.nems.journal.util;

import cn.itcast.nems.common.account.AccountHolder;
import cn.itcast.nems.studentrecord.dao.condition.ApprovalType;
import cn.itcast.nems.studentrecord.dao.dataobject.ApprovalFormQueryModel;

import java.util.List;

public class JournalUtil {
    private JournalUtil() {} ;
    /**
     * <p>
     * 根据审批类型获取重读凭单分页查询条件
     * </p>
     *
     * @param journalIds                                凭单ID
     * @param model                                     凭单查询条件
     * @param approvalType                              审批类型
     * @author zhouwei
     * @since 2023/12/8 1:34 PM
     **/
    public  static <T extends ApprovalFormQueryModel> void invokeByApprovalType (
                                                List<String> journalIds,
                                                T model,
                                                String journalType ,
                                                ApprovalType approvalType)
{
    model.setApprovalType(approvalType);
    model.setJournalType(journalType);
        if (approvalType == ApprovalType.MY_COMMIT) {
            model.setFlowCreatedBy(AccountHolder.getRequiredAccount());
            model.setCreatedBy(AccountHolder.getRequiredAccount());
        } else if (approvalType == ApprovalType.WAIT_APPROVAL) {
            // 待办
            model.setFormIds(journalIds);
            model.setFlowCreatedBy(AccountHolder.getRequiredAccount());
            model.setNotDraft(true);
        } else if (approvalType == ApprovalType.APPROVED) {
            // 已办
            model.setFormIds(journalIds);
            model.setFlowCreatedBy(AccountHolder.getRequiredAccount());
            model.setNotDraft(true);
        } else if (approvalType == ApprovalType.ALL) {
            // 全部
            model.setNotDraft(true);
        }
    }
}
